package util;

public class XmlHelper {
	
	public static String getHeader(String encoding) {
		return "<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>";
	}
	
	public static String getTag(String tagName) {
		return "<" + tagName + "/>";
	}
	
	public static String getTag(String tagName, String atributes) {
		return "<" + tagName + atributes + "/>";
	}
	
	/**
	 * Gets the initial XML tag for an node.
	 * 
	 * @param tagName
	 *            The name of tag
	 * @return The initial tag sintax
	 */
	public static String getOpenTag(String tagName) {
		return "<" + tagName + ">";
	}

	/**
	 * Gets the initial XML tag for an node.
	 * 
	 * @param tagName
	 *            The name of tag
	 * @return The initial tag sintax
	 */
	public static String getOpenTag(String tagName, String atributes) {
		return "<" + tagName + atributes + ">";
	}
	
	/**
	 * Gets the final XML tag for an node.
	 * 
	 * @param tagName
	 *            The name of tag
	 * @return The final tag sintax
	 */
	public static String getEndTag(String tagName) {
		return "</" + tagName + ">";
	}


	public static String getAttribute(String name, String value) {
		return (value != null) ? (" " + name + "=\"" + value + "\"") : "";
	}
}
